package com.example.drools.spring.yc.service.impl;

import com.example.drools.spring.yc.entity.YcEnterpriseEntity;
import com.example.drools.spring.yc.entity.YcUniqueEntity;
import com.example.drools.spring.yc.service.YcUniqueCacheService;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author ddsyw
 * @version 1.0
 * @date 2021/12/31 2:57 下午
 */
@Slf4j
@Service("ycEnterpriseUniqueCacheService")
public class YcEnterpriseUniqueCacheServiceImpl implements YcUniqueCacheService {
  private static final Set<String> OLD_SET = new HashSet<>();

  @Override
  public boolean checkUnique(YcUniqueEntity ycUniqueEntity) {
    YcEnterpriseEntity ycEnterpriseEntity = (YcEnterpriseEntity) ycUniqueEntity;
    return OLD_SET.contains(ycEnterpriseEntity.getPermitNo());
  }

  @PostConstruct
  public void initData()  {
    OLD_SET.add("11111");
    OLD_SET.add("22222");
  }

}
